function showUpload(){
	$("#uploaddiypicture").dialog("open");
}
		var json = "";
		var imgIndex="";
$().ready(function(){
var productId = $("#productId").val();
$.post(
   "showShareProducts",
   {"productId":productId},
   function(data){
   var shareDiv = "<h2 style=margin-left:-85%;>分享产品：</h2><ul style=list-style-type:none;>";
  	 $.each(data.customs,function(index,value){
  	 var url = value.customPic;
     var name = value.customName;
     var customId = value.customId;
  	 var html = "<li style=float:left;width:230px;><div><table><tr><td><a href=showProduct?customId="+customId+">" +
							"    <img src=/"+url+
					     " width=220px;></a></td><tr><td><a href=showProduct?customId="+customId+">"+name+"</a></td></tr></table></div></li>";
  	   shareDiv = shareDiv+html;
  	 });
  	 $("#shareDiv").html(shareDiv);;
   }
); 
  $.post("getAllStyle",{url:'<%=bgPic%>'},function(data){
  var html = "";
     $.each(data.urls,function(index,value){
     html = html+"<li style=float:left;list-style:none outside none; margin-right:10px;><img height=107 width=107 onclick=changeBg('"+value+"') src="+value+"></li>";
     });
     $("#example1").html(html);
  });  

 DY_scroll('.img-scroll','.prev','.next','.img-list',5,false);// true为自动播放，不加此参数或false就默认不自动
 var len  = $("#imgLength").val();
 if(len<5){
   $(".prev").css("display","none");
    $(".next").css("display","none");
 }
});

function add(url){
	var json = $("#json").html();
	var obj = JSON.parse(json);
	var top1 = obj.top;
	var left = obj.left;
	var width = obj.width;
	var height = obj.height;
	addimg2(url,top1,left,width,height);
}
function addimg2(url,top1,left,width,height) {
	var div = document.createElement("div");
	div.setAttribute("id", "img" + index);
	div.setAttribute("style", "position:absolute;left:"+left+"px; top:"+top1+"px;");
	arrayImg.push("img" + index);
   imgIndex = "#img"+index;
 
	var img = document.createElement("img");
	img.setAttribute("src", url);
	var oldW = img.getAttribute("width");
	var oldH = img.getAttribute("height");
	img.setAttribute("height",height+"px");
	var newW = oldW*height/oldH;

	img.setAttribute("width",newW);
	
	img.setAttribute("style", "cursor:move;");
	  
	
	img.setAttribute("id", "pic" + index);
	

	var cancel = document.createElement("img");
	cancel.setAttribute("src", "/img/cancel_03.png");
	cancel
			.setAttribute(
					"style",
					"display:block; position:relative; float:left; left:0; top:0; width:12px; height: 10px");
	cancel.setAttribute("onclick", "cancelimg(" + index + ")");

	var div2 = document.createElement("div");
	div2.setAttribute("style", "width:12px; height: 10px");
	div2.appendChild(cancel);
	div.appendChild(div2);
	div.appendChild(img);
	document.getElementById("bg").appendChild(div);
	$("#img" + index).mouseover(function() {
		$(this).children().eq(0).children().eq(0).fadeIn("slow");
	});
	$("#img" + index).mouseout(function() {
		$(this).children().eq(0).children().eq(0).fadeOut("slow");
	});
	$("#img" + index).draggable({
		containment : '#bg'
	});
	$("#pic" + index).resizable();
	index++;
	$.getJSON("getTypesNameByTypeUrl.action", {
		url : url
	}, function(data) {
		var dd = data.typename;
		if (dd != "" && dd != 'null' && dd != null) {
			var temp = $("#forname").val();
			if (temp == "") {
				temp += dd;
			} else {
				temp += ("." + dd);
			}
			$("#forname").val(temp);
			alert('添加图片的名字：' + temp);
		}
	});
	
}
function SendCar(carname) {
	$.post("SendCarMark.action", {
		CarName : carname
	}, function(data) {
		var carpic = document.getElementById("Carpic");
		carpic.innerHTML = "";
		var l1;
		for ( var i = 0; i < data.jsonob1.length; i++) {
			l1 = document.createElement("div");
			l1.innerHTML = "<img width=100 onclick=add('" + data.jsonob1[i]
					+ "') src='" + data.jsonob1[i] + "' />";
			carpic.appendChild(l1);
		}
	}, "json");
	$.post("getDefaultCarMark",{seriesName:carname},function(data){
	add("CarMark/"+data.typesPic);
	showOthers("CarMark/"+data.typesPic);
	});
}
function inputWordFocus(){
	var tele = document.getElementById("word");
	if (tele.innerHTML == "请输入自定义文字") {
		tele.innerHTML = "";
	}
	tele.style.color = "#000000";
}
function hideTypeSelect(){
	$("#leftlist").slideUp("slow");
	$("#openchexing").show();
}

